package adv7;

import adv6.SuperMarket;

/**
 * @author oldliu
 * @since 1.0
 */
public class AutoSaveThread extends Thread {
    private final SuperMarket sm;

    private boolean runing=true;
    public AutoSaveThread(SuperMarket sm) {
        this.sm = sm;
    }

    public void stopRuning() {
        runing=false;
    }
    @Override
    public void run() {
        while (runing) {
            try {
                sleep(5000);
            } catch (InterruptedException e) {

            }
            SuperMarket.save(sm);
            //System.out.println("auto save ok");
        }
    }
}
